<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">

<head>

	<title>人人康管理系统</title>
	<!-- HTML5 Shim and Respond.js IE11 support of HTML5 elements and media queries -->
	<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
	<!--[if lt IE 11]>
		<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
		<script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
		<![endif]-->
	<!-- Meta -->
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimal-ui">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<meta name="description" content="">
	<meta name="keywords" content="">
	<meta name="author" content="Phoenixcoded">


	<!-- vendor css -->
	<link rel="stylesheet" href="/css/loginstyle.css">
	<style type="text/css">
		.imglogo{ width:130px; height:130px; border-radius:100%; }
		.card{border-radius:10px;}
		/*登录背景设置*/
		.auth-wrapper{
			background:url("/images/body-bg-8.jpg");
			background-repeat:no-repeat;
			background-size:cover;
		}
	</style>

	<!--存储-->
	<script th:src="@{/js/stroage.js}" type="text/javascript" charset="UTF-8"></script>
	<!--通用js-->
	<script th:src="@{/js/comm.js}" type="text/javascript"></script>
	<!--MD5-->
	<script th:src="@{/js/md5.js}" type="text/javascript" charset="UTF-8"></script>

	<!--<script>
		window.onload=function(){
			console.log(hex_md5("123"));
		}
	</script>-->
</head>


<!-- [ auth-signin ] start -->
<div class="auth-wrapper background-img-1">
	<div class="auth-content">
		<div class="card">
			<div class="row align-items-center text-center">
				<div class="col-md-12">
					<div class="card-body">
						<img src="/images/blacklogo.jpg" alt="" class="img-fluid mb-4 imglogo">
						<h4 class="mb-3 f-w-400">登录</h4>
						<div class="form-group mb-3">
							<label class="floating-label" for="Email">登陆账号</label>
							<input type="text" class="form-control" id="Email" placeholder="">
						</div>
						<div class="form-group mb-4">
							<label class="floating-label" for="Password">登录密码</label>
							<input type="password" class="form-control" id="Password" placeholder="">
						</div>
						<div class="form-group mb-4">
							<label class="floating-label" for="Logincode">输入下方验证码</label>
							<input type="text" class="form-control" id="Logincode" placeholder="">

						</div>
						<div style="margin-bottom:20px;border:1px solid #e1e1e1;cursor:pointer; ">
							<canvas id="canvas" width="150px" height="43px" />
						</div>
						<!--<div class="custom-control custom-checkbox text-left mb-4 mt-2">
							<input type="checkbox" class="custom-control-input" id="customCheck1">
							<label class="custom-control-label" for="customCheck1">保存</label>
						</div>-->
						<button id="submitok" class="btn btn-block btn-primary mb-4">确定</button>
						<!--<p class="mb-2 text-muted">Forgot password? <a href="auth-reset-password.html" class="f-w-400">Reset</a></p>
						<p class="mb-0 text-muted">Don’t have an account? <a href="auth-signup.html" class="f-w-400">Signup</a></p>-->
					</div>
				</div>
			</div>
		</div>
	</div>
</div>


<!-- [ auth-signin ] end -->


<!-- 登录验证码 -->
<script th:src="@{/js/jquery-1.9.1.min.js}" type="text/javascript"></script>
<script th:src="@{/js/logincode.js}" type="text/javascript"></script>


<!-- Required Js -->
<script src="/js/vendor-all.min.js"></script>
<script src="/js/bootstrap.min.js"></script>
<script src="/js/ripple.js"></script>
<script src="/js/pcoded.min.js"></script>
<!-- sweet alert Js -->
<script src="/js/sweetalert.min.js"></script>
<!--<script src="/static/js/ac-alert.js"></script>-->

<script>
	var ServerIP=[(${ServerIP!=null?'"'+ServerIP+'"':'"'+'"'})];
	//var ServerIP=null;
	$(document).ready(function() {
		$('#submitok').on('click',async function() {
			var Email=$("#Email").val();
			var Password=$("#Password").val();
			if(/\S+/.test(Email)===false){
				swal("登录账号有误", "请输入正确账号!", "error");
				$("#Email").focus();
				return false;
			}
			if(/\S+/.test(Password)===false){
				swal("登录密码不正确", "请输入正确密码!", "error");
				return false;
			}
			var val = $("#Logincode").val().toLowerCase();
			if (/\S/.test(val)===false) {
				swal("验证码错误", "请输入正确验证码!", "error");
				$("#Logincode").val('');
				draw(show_num);
				return false;
			}
			var num = show_num.join(""); //show_num变量在上方logincode.js中定义
			//console.log("js生成码：",num);
			if(val != num) {
				swal("验证码错误", "请输入正确验证码!", "error");
				$("#Logincode").val('');
				draw(show_num);
				return false;
			}
			var data={
				adminname:Email,
				adminpwd:hex_md5(Password)
				//adminpwd:Password
			};
			console.log("登录data:",data);
			var res=await SyncJson(ServerIP+'api/adminlogin',data);
			console.log("登录结果111===>:",res);
			if(res.code===200){
				myStorage.setItem("token",res.result.token);
				if(myStorage.getItem("token")!=null && myStorage.getItem("token")!=undefined && myStorage.getItem("token")!=""){
					window.location.href="/bg/index";
				}
			}else{
				swal("登录失败", "账号或密码不正确!", "error");
			}
		});
	});
</script>




</html>
